<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: ActionView::Helpers::NumberHelper</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">ActionView::Helpers::NumberHelper</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../../files/lib/localization_simplified_rb.html">
                lib/localization_simplified.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Give default settings to <a
href="NumberHelper.html#M000006">number_to_currency</a>()
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000006">number_to_currency</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">



    <div id="aliases-list">
      <h3 class="section-bar">External Aliases</h3>

      <div class="name-list">
                        <table summary="aliases">
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">number_to_currency</td>
          <td>-&gt;</td>
          <td class="context-item-value">orig_number_to_currency</td>
        </tr>
                        </table>
      </div>
    </div>


      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000006" class="method-detail">
        <a name="M000006"></a>

        <div class="method-heading">
          <a href="#M000006" class="method-signature">
          <span class="method-name">number_to_currency</span><span class="method-args">(number, options = {})</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
modify <a href="NumberHelper.html#M000006">number_to_currency</a> to accept
:order option
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000006-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000006-source">
<pre>
     <span class="ruby-comment cmt"># File lib/localization_simplified.rb, line 143</span>
143:       <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">number_to_currency</span>(<span class="ruby-identifier">number</span>, <span class="ruby-identifier">options</span> = {})
144:         <span class="ruby-comment cmt"># Blend default options with localized currency options</span>
145:         <span class="ruby-identifier">options</span>.<span class="ruby-identifier">reverse_merge!</span>(<span class="ruby-constant">LocalizationSimplified</span><span class="ruby-operator">::</span><span class="ruby-constant">NumberHelper</span><span class="ruby-operator">::</span><span class="ruby-constant">CurrencyOptions</span>)
146:         <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:order</span>] <span class="ruby-operator">||=</span> [<span class="ruby-identifier">:unit</span>, <span class="ruby-identifier">:number</span>]
147:         <span class="ruby-identifier">options</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">stringify_keys</span>
148:         <span class="ruby-identifier">precision</span>, <span class="ruby-identifier">unit</span>, <span class="ruby-identifier">separator</span>, <span class="ruby-identifier">delimiter</span> = <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value str">&quot;precision&quot;</span>) { <span class="ruby-value">2</span> }, <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value str">&quot;unit&quot;</span>) { <span class="ruby-value str">&quot;$&quot;</span> }, <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value str">&quot;separator&quot;</span>) { <span class="ruby-value str">&quot;.&quot;</span> }, <span class="ruby-identifier">options</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-value str">&quot;delimiter&quot;</span>) { <span class="ruby-value str">&quot;,&quot;</span> }
149:         <span class="ruby-identifier">separator</span> = <span class="ruby-value str">&quot;&quot;</span> <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">precision</span> <span class="ruby-operator">&gt;</span> <span class="ruby-value">0</span>
150: 
151:         <span class="ruby-comment cmt">#add leading space before trailing unit</span>
152:         <span class="ruby-identifier">unit</span> = <span class="ruby-value str">&quot; &quot;</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">unit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-value str">&quot;order&quot;</span>] <span class="ruby-operator">==</span> [<span class="ruby-identifier">:number</span>, <span class="ruby-identifier">:unit</span>]
153:         <span class="ruby-identifier">output</span> = <span class="ruby-value str">''</span>
154:         <span class="ruby-keyword kw">begin</span>
155:           <span class="ruby-identifier">options</span>[<span class="ruby-value str">&quot;order&quot;</span>].<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">param</span><span class="ruby-operator">|</span>
156:             <span class="ruby-keyword kw">case</span> <span class="ruby-identifier">param</span>
157:               <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:unit</span>
158:                 <span class="ruby-identifier">output</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">unit</span>
159:               <span class="ruby-keyword kw">when</span> <span class="ruby-identifier">:number</span>
160:                 <span class="ruby-identifier">parts</span> = <span class="ruby-identifier">number_with_precision</span>(<span class="ruby-identifier">number</span>, <span class="ruby-identifier">precision</span>).<span class="ruby-identifier">split</span>(<span class="ruby-value str">'.'</span>)
161:                 <span class="ruby-identifier">output</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">number_with_delimiter</span>(<span class="ruby-identifier">parts</span>[<span class="ruby-value">0</span>], <span class="ruby-identifier">delimiter</span>) <span class="ruby-operator">+</span> <span class="ruby-identifier">separator</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">parts</span>[<span class="ruby-value">1</span>].<span class="ruby-identifier">to_s</span>
162:             <span class="ruby-keyword kw">end</span>
163:           <span class="ruby-keyword kw">end</span>
164:         <span class="ruby-keyword kw">rescue</span>
165:           <span class="ruby-identifier">output</span> = <span class="ruby-identifier">number</span>
166:         <span class="ruby-keyword kw">end</span>
167:         <span class="ruby-identifier">output</span>
168:       <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>